<!DOCTYPE html>
<HTML>
<HEAD><meta name="viewport" content="width=device-width, initial-scale=1">
<Title>Discrete Heat Map</Title>
<link type='text/css' rel='Stylesheet' href="maxchartapi.css" />
</HEAD>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">

<p class="heading0">ChartDirector 7.0 (Java Edition)</p>
<p class="heading1">Discrete Heat Map</p>
<hr class="separator">
<div class="content">
<img src="images/discreteheatmap.png" width='520' height='470'>
<br><br>
This example demonstrates the basic steps in creating a discrete heat map.<br><br>
A discrete heat map consists of rectangular cells in a grid of which the cell color depends on its data value.<br><br>
<ul><li> Create an <a href="XYChart.htm">XYChart</a> object using <a href="XYChart.XYChart.htm">XYChart.XYChart</a>.<br><br>
<li> Specify the plot area of the chart using <a href="XYChart.setPlotArea.htm">XYChart.setPlotArea</a>. The plot area is the rectangle bounded by the x and y axes. You should leave some margin on the outside of the plot area for axis labels, chart titles, etc.<br><br>
<li> Add a discrete heat map layer using <a href="XYChart.addDiscreteHeatMapLayer.htm">XYChart.addDiscreteHeatMapLayer</a>.<br><br>
<li> Specify the labels on the x-axis and y-axis using <a href="Axis.setLabels.htm">Axis.setLabels</a>. Shift the labels    by 0.5 units using <a href="Axis.setOffset.htm">Axis.setOffset</a> to align the labels with the cell center. (The    default is to align the labels with the grid lines.)<br><br>
<li> The color axis (visually represented as the color legend) is positioned vertically to the right of the plot area using <a href="DiscreteHeatMapLayer.setColorAxis.htm">DiscreteHeatMapLayer.setColorAxis</a>.<br><br>
<li> Assign the chart to the WebChartViewer using <a href="WebChartViewer.setChart.htm">WebChartViewer.setChart</a>, and insert it to the web page using <a href="WebChartViewer.renderHTML.htm">WebChartViewer.renderHTML</a>.<br><br>
<li> Generate tool tips for the chart using <a href="BaseChart.getHTMLImageMap.htm">BaseChart.getHTMLImageMap</a>.</ul>
</div>
<p class="heading1a">Source Code Listing</p>
<div class="content">
<b>[JSP Version]</b> jspdemo/discreteheatmap.jsp
<div class='codeblock'><code class='pre'>&lt;%@page import="ChartDirector.*, java.util.*" %&gt;
&lt;%
// The x-axis and y-axis labels
String[] xLabels = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
String[] yLabels = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};

// Random data for the 10 x 10 cells
RanSeries r = new RanSeries(2);
double[] zData = r.get2DSeries(xLabels.length, yLabels.length, 0, 100);

// Create an XYChart object of size 520 x 470 pixels.
XYChart c = new XYChart(520, 470);

// Set the plotarea at (50, 30) and of size 400 x 400 pixels.
PlotArea p = c.setPlotArea(50, 30, 400, 400);

// Create a discrete heat map with 10 x 10 cells
DiscreteHeatMapLayer layer = c.addDiscreteHeatMapLayer(zData, xLabels.length);

// Set the x-axis labels. Use 8pt Arial Bold font. Set axis stem to transparent, so only the labels
// are visible. Set 0.5 offset to position the labels in between the grid lines.
c.xAxis().setLabels(xLabels);
c.xAxis().setLabelStyle("Arial Bold", 8);
c.xAxis().setColors(Chart.Transparent, Chart.TextColor);
c.xAxis().setLabelOffset(0.5);
c.xAxis().setTitle("X Axis Title Placeholder", "Arial Bold", 12);

// Set the y-axis labels. Use 8pt Arial Bold font. Set axis stem to transparent, so only the labels
// are visible. Set 0.5 offset to position the labels in between the grid lines.
c.yAxis().setLabels(yLabels);
c.yAxis().setLabelStyle("Arial Bold", 8);
c.yAxis().setColors(Chart.Transparent, Chart.TextColor);
c.yAxis().setLabelOffset(0.5);
c.yAxis().setTitle("Y Axis Title Placeholder", "Arial Bold", 12);

// Position the color axis 20 pixels to the right of the plot area and of the same height as the
// plot area. Put the labels on the right side of the color axis. Use 8pt Arial Bold font for the
// labels.
ColorAxis cAxis = layer.setColorAxis(p.getRightX() + 20, p.getTopY(), Chart.TopLeft, p.getHeight(),
    Chart.Right);
cAxis.setLabelStyle("Arial Bold", 8);

// Output the chart
WebChartViewer viewer = new WebChartViewer(request, "chart1");
viewer.setChart(c, Chart.SVG);

// Include tool tip for the chart
viewer.setImageMap(c.getHTMLImageMap("", "", "title='&lt;*cdml*&gt;({xLabel}, {yLabel}) = {z|2}'"));
%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Discrete Heat Map&lt;/title&gt;
    &lt;!-- Include ChartDirector Javascript Library to support chart interactions --&gt;
    &lt;script type="text/javascript" src="cdjcv.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body style="margin:5px 0px 0px 5px"&gt;
    &lt;div style="font:bold 18pt verdana;"&gt;
        Discrete Heat Map
    &lt;/div&gt;
    &lt;hr style="border:solid 1px #000080; background:#000080" /&gt;
    &lt;div style="font:10pt verdana; margin-bottom:1.5em"&gt;
        &lt;a href="viewsource.jsp?file=&lt;%=request.getServletPath()%&gt;"&gt;View Source Code&lt;/a&gt;
    &lt;/div&gt;
    &lt;!-- ****** Here is the chart image ****** --&gt;
    &lt;%= viewer.renderHTML(response) %&gt;
&lt;/body&gt;
&lt;/html&gt;</code></div>
</div>
<br><hr class="separator"><div class="copyright">&copy; 2022 Advanced Software Engineering Limited. All rights reserved.</div>
</body>
</HTML>
